package com.fau.cm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc  短信信息表
 * @author hufq
 * @datetime 2014年10月15日,上午10:35:07
 */
@Entity
@Table(name = "medical_call_sms")
public class MedicalCallSms  implements Serializable, JSONAware{

	private static final long serialVersionUID = 7503991036811552578L;
	
	private String id;
	
	@NotBlank(message = "接收手机号不能为空！")
	@Length(max = 15, message = "接收手机号长度需要在0和15之间")
	private String phoneNum;               		// 接收手机号
	
	@NotBlank(message = "发送内容不能为空！")
	@Length(max = 85, message = "发送内容长度需要在0和85之间")
	private String content;    				 	// 发送内容
	
	private Date sendTime;    				 	// 发送时间
	
	@Length(max = 32, message = "发送坐席人id长度需要在0和32之间")
	private String sendSeat;                 	// 发送坐席人id
	private String sendSeatName;				// 座席用户名
	
	@Length(max = 5, message = "发送状态长度需要在0和5之间")
	private String sendStatus;  			 	// 发送状态   
	private String statusVal;					// 发送状态字典表值
	
	private String centerId;					// 中心ID
	private String groupId;						// 组ID
	private String customerId;					// 客户ID
	private String hospitalId;					// 医院企业id
	
	private Date createTime = new Date();    	// 创建时间
	private Date updateTime = new Date();    	// 更新时间
	private String ids;							// 多个id
	private String keyType; 					// 字典表短信类型
	private String keyPid; 						// 父id
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "ID", length = 32)
	public String getId() {
		return id;
	} 

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "phone_num", length = 15)
	public String getPhoneNum() {
		return phoneNum;
	}

	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}

	@Column(name = "content", length = 255)
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "send_time")
	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}
	
	@Column(name = "send_seat", length = 32)
	public String getSendSeat() {
		return sendSeat;
	}

	public void setSendSeat(String sendSeat) {
		this.sendSeat = sendSeat;
	}
	
	@Transient
	public String getSendSeatName() {
		return sendSeatName;
	}

	public void setSendSeatName(String sendSeatName) {
		this.sendSeatName = sendSeatName;
	}

	@Column(name = "send_status", length = 5)
	public String getSendStatus() {
		return sendStatus;
	}

	public void setSendStatus(String sendStatus) {
		this.sendStatus = sendStatus;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	@Transient
	public String getStatusVal() {
		return statusVal;
	}

	public void setStatusVal(String statusVal) {
		this.statusVal = statusVal;
	}
	
	@Column(name = "center_id", length = 32)
	public String getCenterId() {
		return centerId;
	}

	public void setCenterId(String centerId) {
		this.centerId = centerId;
	}

	@Column(name = "group_id", length = 32)
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	@Column(name = "customer_id", length = 32)
	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@Transient
	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}

	@Transient
	public String getKeyType() {
		return keyType;
	}

	public void setKeyType(String keyType) {
		this.keyType = keyType;
	}

	@Transient
	public String getKeyPid() {
		return keyPid;
	}

	public void setKeyPid(String keyPid) {
		this.keyPid = keyPid;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("phoneNum", phoneNum);
		obj.put("sendSeatName", sendSeatName);
		obj.put("content", content);
		obj.put("statusVal", statusVal);
		obj.put("sendStatus", sendStatus);
		obj.put("centerId", centerId);
		obj.put("groupId", groupId);
		obj.put("sendSeat", sendSeat);
		
		if(this.sendTime != null){
			obj.put("sendTime", DateFormatUtils.format(this.sendTime,"yyyy-MM-dd HH:mm:ss"));
		}
		obj.put("updateTime", DateFormatUtils.format(this.updateTime,"yyyy-MM-dd HH:mm:ss"));
		obj.put("createTime", DateFormatUtils.format(this.createTime,"yyyy-MM-dd HH:mm:ss"));
		return obj.toString();
	}
	
}
